# Contributor: Andy Postnikov <apostnikov@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php82-snappy
_extname=snappy
pkgver=0.2.1
pkgrel=1
pkgdesc="Snappy extension for PHP 8.2"
url="https://github.com/kjdev/php-ext-snappy"
arch="all"
license="PHP-3.01"
_phpv=82
_php=php$_phpv
depends="$_php-common"
makedepends="$_php-dev $_php-pecl-apcu snappy-dev"
source="php-$_extname-$pkgver.tar.gz::https://github.com/kjdev/php-ext-snappy/archive/$pkgver.tar.gz
	https://github.com/kjdev/php-ext-snappy/commit/c27f830dcfe6c41eb2619a374de10fd0597f4939.patch
	"
builddir="$srcdir/php-ext-snappy-$pkgver"

build() {
	phpize$_phpv
	./configure \
		--prefix=/usr \
		--with-php-config=php-config$_phpv \
		--with-snappy-includedir
	make
}

check() {
	local _modules=/usr/lib/$_php/modules
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test \
		SKIP_ONLINE_TESTS=1 PHP_TEST_SHARED_EXTENSIONS=" \
		-d extension=$_modules/apcu.so \
		-d extension=modules/$_extname.so" TESTS=--show-diff
	$_php -d extension=modules/$_extname.so --ri $_extname
}

package() {
	make INSTALL_ROOT="$pkgdir"/ install
	local confdir="$pkgdir"/etc/$_php/conf.d
	install -d $confdir
	echo "extension=$_extname" > $confdir/50_$_extname.ini
}

sha512sums="
51cdfe7c5d020cb954cbf555038aca8398867584a587eb838f07089612d3978a182d0bc04015608a2aaf71bf9a5b5896e5d92b56f3b2d5fe9e1116f9509acb1e  php-snappy-0.2.1.tar.gz
4f45438e6f5b8784bff45c5791628af905c70a4b1adf1f3b7248f52d7b41648b07e10e833f3f3ae60f24d421ad302a8a1ab4e464697df9bc36b8fc7a3f0cb3cc  c27f830dcfe6c41eb2619a374de10fd0597f4939.patch
"
